"use strict";
cc._RF.push(module, '022dbelkSNHvro3/V3+ShLh', '_WhoElseIsHereResultHandler');
// CustomResultHandler/_WhoElseIsHereResultHandler.js

"use strict";

function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

// @import
var mod_Asnyc = require("../_Async");

var mod_Global = require("../_Global");

var mod_HeroCreator = require("../_HeroCreator");

var CHeroAction = require("../CHeroAction"); // @export


module.exports = {
  /** @override */
  handle: function handle(oWhoElseIsHereResult) {
    if (!oWhoElseIsHereResult) {
      return;
    } // 获取用户数组


    var oUserArray = oWhoElseIsHereResult.userInfo;

    if (!oUserArray || !Array.isArray(oUserArray) || oUserArray.length <= 0) {
      return;
    }

    var _loop = function _loop() {
      var oParam = _step.value;

      if (!oParam || !oParam.userId || oParam.userId == mod_Global.myUserId) {
        // 如果用户 Id 为空, 
        // 或者是我自己,
        // 那么就不要创建英雄了...
        return "continue";
      } // 获取用户 Id


      var nUserId = oParam.userId;
      var strUserId = nUserId.toString();
      var oTmpHero = null;
      mod_Asnyc.serial( // step000
      // 看看是否已有英雄
      function (funCb000) {
        // 看看是否已有英雄
        oTmpHero = mod_Global.heroMap[strUserId];
        funCb000();
      }, // step010
      // 如果没有英雄就创建一个新的
      function (funCb010) {
        if (oTmpHero) {
          funCb010();
          return;
        } // 创建并添加一个新的英雄


        mod_HeroCreator.createAHero(oParam, function (oNewHero) {
          if (null == oNewHero) {
            return;
          }

          cc.Canvas.instance.node.addChild(oNewHero); // 添加英雄到字典

          mod_Global.heroMap[strUserId] = oNewHero;
          oTmpHero = oNewHero;
          funCb010();
        });
      }, // step020
      // 将英雄移动到指定位置
      function (funCb020) {
        var oMoveState = oParam.moveState;

        if (oMoveState) {
          oTmpHero.getComponent(CHeroAction).moveToAdv(oMoveState.fromPosX, oMoveState.fromPosY, oMoveState.toPosX, oMoveState.toPosY, oMoveState.startTime);
        }

        funCb020();
      });
    };

    for (var _iterator = _createForOfIteratorHelperLoose(oUserArray), _step; !(_step = _iterator()).done;) {
      var _ret = _loop();

      if (_ret === "continue") continue;
    }
  }
};

cc._RF.pop();